import { defineStore } from 'pinia';

import {
  goodsListApi,
  goodsDelApi,
  goodsAddApi,
  goodsEditApi,
  goodsTypeListApi,
  goodsTypeAddApi,
  goodsTypeUpdateApi,
  goodsTypeDeleteApi,
} from '/@/api/locality/commodity';
import { store } from '/@/store';

interface DashboardData {
  commodity: any;
}

export const commodityStore = defineStore({
  id: 'app-commodity',
  state: (): DashboardData => ({
    commodity: [],
  }),
  getters: {},
  actions: {
    async GetgoodsList(params) {
      const data = goodsListApi(params);
      return data;
    },
    async goodsDel(params) {
      const data = goodsDelApi(params);
      return data;
    },
    async goodsAdd(params) {
      const data = goodsAddApi(params);
      return data;
    },
    async goodsEdit(params) {
      const data = goodsEditApi(params);
      return data;
    },
    async getgoodsType(params) {
      const data = goodsTypeListApi(params);
      return data;
    },
    async goodsTypeAdd(params) {
      const data = goodsTypeAddApi(params);
      return data;
    },
    async goodsTypeEdit(params) {
      const data = goodsTypeUpdateApi(params);
      return data;
    },
    async goodsTypeDelete(params) {
      const data = goodsTypeDeleteApi(params);
      return data;
    },
  },
});

export function useUserStoreWithOut() {
  return commodityStore(store);
}
